// 订单相关类型定义
export interface Order {
  id: string;
  orderNumber: string;
  userName: string; // 用户姓名
  phone: string; // 手机号码
  totalRolls: number; // 总出库量
  orderType: '镇内订单' | '镇外订单'; // 订单类型：镇内订单、镇外订单
  orderDate: string; // 下单日期
  orderTime: string; // 下单时间
  status: 'pending' | 'processing' | 'completed' | 'cancelled'; // 订单状态
  createdAt: string;
  updatedAt: string;
  products: OrderProduct[]; // 订单包含的产品列表
  notes?: string;
}

// 订单产品关联
export interface OrderProduct {
  id: string;
  orderId: string;
  productId: string;
  productName: string; // 产品名称
  skuCode: string; // SKU编码
  rolls: number; // 出库量
  unitPrice: number; // 单价
  totalPrice: number; // 小计
}

// 产品信息
export interface Product {
  id: string;
  name: string;
  skuCode: string;
  unit: string;
  unitPrice: number;
  stock: number; // 库存
  createdAt: string;
  updatedAt: string;
}

export interface Vehicle {
  id: string;
  plateNumber: string;
  type: string;
  capacity: number;
  status: 'available' | 'in_use' | 'maintenance' | 'offline';
  location: {
    lat: number;
    lng: number;
    address: string;
  };
  driverId: string;
  driverName: string;
  driverPhone: string;
  currentOrderId?: string;
  fuelConsumption: number;
  mileage: number;
  lastMaintenance: string;
}

export interface Route {
  id: string;
  name: string;
  origin: string;
  destination: string;
  distance: number;
  estimatedTime: number;
  waypoints: Array<{
    name: string;
    lat: number;
    lng: number;
  }>;
  vehicleTypes: string[];
  isActive: boolean;
  createdAt: string;
}

export interface Financial {
  id: string;
  type: 'income' | 'expense';
  category: string;
  amount: number;
  description: string;
  orderId?: string;
  vehicleId?: string;
  date: string;
  status: 'pending' | 'completed' | 'cancelled';
  paymentMethod?: string;
  invoiceNumber?: string;
}

export interface DashboardStats {
  totalOrders: number;
  pendingOrders: number;
  completedOrders: number;
  exceptionOrders: number;
  totalRevenue: number;
  totalCost: number;
  activeVehicles: number;
  totalVehicles: number;
  onTimeDeliveryRate: number;
  customerSatisfaction: number;
}

// 通知相关类型
export interface Notification {
  id: string;
  type: 'info' | 'warning' | 'error' | 'success';
  title: string;
  message: string;
  isRead: boolean;
  createdAt: string;
  actionUrl?: string;
  actionText?: string;
  relatedId?: string;
  priority: 'high' | 'medium' | 'low';
}

// 货物管理类型
export interface Cargo {
  id: string;
  name: string;
  specification?: string;
  unit: string;
  createdAt: string;
  updatedAt: string;
}

// 用户类型
export interface User {
  id: string;
  username: string;
  email: string;
  role: 'admin' | 'manager' | 'operator';
  name: string;
  avatar?: string;
}